package com.one.pass.controller;

import com.one.pass.controller.req.BatchPayReq;
import com.one.pass.controller.req.UserTradeReq;
import com.one.pass.dal.AccountMoney;
import com.one.pass.service.MoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/onePass")
public class MoneyController {

    @Autowired
    private MoneyService moneyService;


    // 处理批量充值请求的API
    @PostMapping("/batchPay")
    public Map<String, Object> batchPay(@RequestBody BatchPayReq batchPayReq) {
        return moneyService.batchPay(batchPayReq);  // 调用MoneyService的batchPay方法处理请求
    }

    // 处理用户间转账请求的API

    @PostMapping("/userTrade")
    public Map<String, Object> userTrade(@RequestBody UserTradeReq userTradeReq) {
        userTradeReq.setUuid(moneyService.getReId());  // 设置请求的唯一标识符
        return moneyService.userTrade(userTradeReq);  // 调用MoneyService的userTrade方法处理请求
    }

    // 查询用户账户金额的API
    @PostMapping("/queryUserAmount")
    public Object queryUserAmount(@RequestBody List<Long> ids) {
        return moneyService.queryUserAmount(ids);  // 调用MoneyService的queryUserAmount方法处理请求
    }
}
